clear all;

load('mig.mat');

mig_lb(1:ntheta)=0;
mig_ub(1:ntheta)=0;
z=2.1;
[~,z_index]=min(abs(gridz-z));

for i=1:ntheta
    temp=find(mig_2to1(z_index,:,i)==1);
    if ~isempty(temp)
        mig_lb(i)=min(temp);
        mig_ub(i)=max(temp);
    end
end

index=find(mig_lb~=0);

x_highkappa=gridb(mig_lb(index));
y_highkappa=gridtheta(index);

save('result_OA8_B.mat','x_highkappa','y_highkappa')